<?php

use Biz\service\course\CourseOrder as sCourseOrder;

class CreateOrderNoAction extends ActionPlugin
{
    const USER_LEVEL = self::LEVEL_REALNAME;

    public function main()
    {
        $courseId = $this->getRequest()->getPost('course_id', 0);
        if ($courseId && $this->uid) {
            $orderNo = sCourseOrder::createOrderNo($courseId, $this->uid);
            if (empty($orderNo)) {
                throw new \Exception('当前课程无法购买');
            }
        } else {
            throw  new \Exception('参数错误');
        }
        $data = ['order_no' => $orderNo];
        $this->setSuccess($data);
    }
}